home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / lfs / lfsInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  7.1 KB  |  210 lines

  1. /*
  2.  * lfsInt.h --
  3.  *
  4.  *    Type and data uses internally to the LFS module.
  5.  *
  6.  * Copyright 1989 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/lfs/lfsInt.h,v 1.16 92/09/27 23:36:32 shirriff Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _LFSINT
  19. #define _LFSINT
  20.  
  21. #include <sprite.h>
  22. #include <fs.h>
  23. #include <fsconsist.h>
  24. #include <user/fs.h>
  25. #include <lfs.h>
  26. #include <lfsTypes.h>
  27. #include <lfsDesc.h>
  28. #include <lfsDescMapInt.h>
  29. #include <lfsDescInt.h>
  30. #include <lfsSuperBlock.h>
  31. #include <lfsSegUsageInt.h>
  32. #include <lfsFileLayoutInt.h>
  33. #include <lfsDirLogInt.h>
  34. #include <lfsMemInt.h>
  35. #include <lfsStats.h>
  36.  
  37. #include <fsdm.h>
  38.  
  39. /*
  40.  * So we can use printf and bzero, bcopy in the lfs module.
  41.  */
  42. #include <stdio.h> 
  43. #include <bstring.h>
  44.  
  45. /* constants */
  46. /*
  47.  * Flags for checkpoint callback.
  48.  * LFS_CHECKPOINT_DETACH - This checkpoint is part of a file system detach.
  49.  *                       Any data structures malloc'ed for this file
  50.  *                   system during attach should be freed.
  51.  * LFS_CHECKPOINT_NOSEG_WAIT - This checkpoint shouldn't wait for clean
  52.  *                segments because it is a checkpoint after
  53.  *                a cleaning.
  54.  * LFS_CHECKPOINT_WRITEBACK - This checkpoint is being done for a domain
  55.  *                  writeback operation.
  56.  * LFS_CHECKPOINT_TIMER - This checkpoint is part of the regular callback.
  57.  * LFS_CHECKPOINT_CLEANER - This checkpoint is part of the cleaner.
  58.  * 
  59.  */
  60. #define    LFS_CHECKPOINT_DETACH         0x1
  61. #define    LFS_CHECKPOINT_NOSEG_WAIT     0x2
  62. #define    LFS_CHECKPOINT_WRITEBACK     0x4
  63. #define    LFS_CHECKPOINT_TIMER         0x8
  64. #define    LFS_CHECKPOINT_CLEANER         0x10
  65.  
  66. /*
  67.  * Possible values for activeFlags:
  68.  * LFS_CLEANER_ACTIVE      - A segment cleaner process is active on this file 
  69.  *                system.
  70.  * LFS_WRITE_ACTIVE      - Someone is actively writing to the log.
  71.  * LFS_CHECKPOINT_ACTIVE  - A checkpoint is active on this file system.
  72.  * LFS_SHUTDOWN_ACTIVE    - The file system is about to be shutdown.
  73.  * LFS_CHECKPOINTWAIT_ACTIVE - Someone is waiting for a checkpoint to be
  74.  *                   performed.
  75.  * LFS_CLEANER_CHECKPOINT_ACTIVE - A segment cleaner is doing a checkpoint.
  76.  * LFS_SYNC_CHECKPOINT_ACTIVE - A segment cleaner is doing a checkpoint.
  77.  * LFS_CLEANSEGWAIT_ACTIVE - Someone is waiting for clean segments to be
  78.  *                 generated.
  79.  */
  80.  
  81. #define    LFS_WRITE_ACTIVE      0x1
  82. #define    LFS_CLEANER_ACTIVE     0x10
  83. #define    LFS_SHUTDOWN_ACTIVE     0x40
  84. #define    LFS_CHECKPOINTWAIT_ACTIVE 0x80
  85. #define    LFS_SYNC_CHECKPOINT_ACTIVE 0x100
  86. #define    LFS_CLEANER_CHECKPOINT_ACTIVE 0x200
  87. #define    LFS_CHECKPOINT_ACTIVE 0x300
  88. #define    LFS_CLEANSEGWAIT_ACTIVE    0x400
  89.  
  90. extern int lfsMinNumberToClean;
  91.  
  92. /*
  93.  * This is for ASPLOS stats only.  Remove when that's done.  -Mary 2/16/92.
  94.  */
  95. extern Boolean Lfs_DoASPLOSStats;
  96.  
  97. /* Useful macros for LFS.
  98.  *
  99.  * LfsFromDomainPtr(domainPtr) - Return the Lfs data stucture for a Fsdm_domain.
  100.  *
  101.  * LfsSegSize(lfsPtr)    - Return the segment size in bytes.
  102.  * LfsSegSizeInBlocks(lfsPtr) - Return the segment size in blocks.
  103.  * LfsBlockSize(lfsPtr)       - Return the block size.
  104.  * LfsBytesToBlocks(lfsPtr, bytes) - Convert bytes into the number of blocks
  105.  *                     it would take to contain the bytes.
  106.  * LfsBlocksToBytes(lfsPtr, blocks) - Convert from blocks into bytes.
  107.  * LfsSegNumToDiskAddress(lfsPtr, segNum) - Convert a segment number into
  108.  *                        a disk address.
  109.  * LfsBlockToSegmentNum(lfsPtr, diskAdress)  - Compute the segment number 
  110.  *                     of a disk  address .
  111.  * LfsIsCleanerProcess(lfsPtr) - Return TRUE if current process is a cleaner.
  112.  *
  113.  * LfsGetCurrentTimestamp(lfsPtr) - Return the current file system timestamp
  114.  */
  115.  
  116. #define    LfsFromDomainPtr(domainPtr) ((Lfs *) ((domainPtr)->clientData))
  117.  
  118. #define    LfsSegSize(lfsPtr) ((lfsPtr)->usageArray.params.segmentSize)
  119.  
  120. #define    LfsSegSizeInBlocks(lfsPtr) \
  121.             (LfsSegSize(lfsPtr)>>(lfsPtr)->blockSizeShift)
  122.  
  123. #define    LfsBlockSize(lfsPtr) ((lfsPtr)->superBlock.hdr.blockSize)
  124.  
  125. #define    LfsBytesToBlocks(lfsPtr, bytes)    \
  126.      (((bytes) + (LfsBlockSize(lfsPtr)-1))>>(lfsPtr)->blockSizeShift)
  127.  
  128. #define    LfsBlocksToBytes(lfsPtr, blocks) ((blocks)<<(lfsPtr)->blockSizeShift)
  129.  
  130.  
  131. #define LfsValidSegmentNum(lfsPtr, segNum) (((segNum) >= 0) && \
  132.         ((segNum) < (lfsPtr)->usageArray.params.numberSegments))
  133.  
  134.  
  135. #define LfsSegNumToDiskAddress(lfsPtr, segNum, diskAddrPtr) \
  136.         LfsOffsetToDiskAddr(  \
  137.              ((lfsPtr)->superBlock.hdr.logStartOffset + \
  138.         (LfsSegSizeInBlocks((lfsPtr)) * (segNum))), diskAddrPtr)
  139.  
  140. #define LfsDiskAddrToSegmentNum(lfsPtr, diskAddress) \
  141.         ((LfsDiskAddrToOffset(diskAddress) - \
  142.                 (lfsPtr)->superBlock.hdr.logStartOffset) / \
  143.                      LfsSegSizeInBlocks((lfsPtr)))
  144.  
  145. #define    LfsGetCurrentTimestamp(lfsPtr)    (++((lfsPtr)->checkPoint.timestamp))
  146.  
  147. #define    LfsIsCleanerProcess(lfsPtr) \
  148.         (Proc_GetCurrentProc() == (lfsPtr)->cleanerProcPtr)
  149.  
  150. /*
  151.  * Attach detach routines. 
  152.  */
  153. extern ReturnStatus LfsLoadFileSystem _ARGS_((Lfs *lfsPtr, int flags));
  154. extern ReturnStatus LfsDetachFileSystem _ARGS_((Lfs *lfsPtr));
  155. extern ReturnStatus LfsCheckPointFileSystem _ARGS_((Lfs *lfsPtr, int flags));
  156.  
  157.  
  158.  
  159. /*
  160.  * Utility  routines.
  161.  */
  162. extern int LfsLogBase2 _ARGS_((unsigned int val));
  163. extern void LfsError _ARGS_((Lfs *lfsPtr, ReturnStatus status, char *message));
  164. extern void LfsSegCleanStart _ARGS_((Lfs *lfsPtr));
  165. extern void LfsWaitForCheckPoint _ARGS_((Lfs *lfsPtr));
  166. extern void LfsSegmentWriteProc _ARGS_((ClientData clientData,
  167.                 Proc_CallInfo *callInfoPtr));
  168. extern void LfsWaitForCleanSegments _ARGS_((Lfs *lfsPtr));
  169.  
  170. extern void Lfs_ReallocBlock _ARGS_((ClientData data, 
  171.                 Proc_CallInfo *callInfoPtr));
  172. /*
  173.  * Second parameter below is for ASPLOS measurements and can be removed
  174.  * after that's all over.  Mary 2/14/92.
  175.  */
  176. extern Boolean Lfs_StartWriteBack _ARGS_((Fscache_Backend *backendPtr, Boolean fileFsynced));
  177. extern void LfsStopWriteBack _ARGS_((Lfs *lfsPtr));
  178. extern Boolean LfsMoreToWriteBack _ARGS_((Lfs *lfsPtr));
  179. extern Fscache_Backend *LfsCacheBackendInit _ARGS_((Lfs *lfsPtr));
  180. /*
  181.  * I/o routines. 
  182.  */
  183. extern ReturnStatus LfsReadBytes _ARGS_((Lfs *lfsPtr, LfsDiskAddr diskAddress, 
  184.             int numBytes, char *bufferPtr));
  185. extern ReturnStatus LfsWriteBytes _ARGS_((Lfs *lfsPtr, LfsDiskAddr diskAddress, 
  186.             int numBytes, char *bufferPtr));
  187. extern void LfsCheckRead _ARGS_((Lfs *lfsPtr, LfsDiskAddr diskAddress, 
  188.                 int numBytes));
  189.  
  190. /*
  191.  * File index routines. 
  192.  */
  193. extern ReturnStatus LfsFile_GetIndex _ARGS_((Fsio_FileIOHandle *handlePtr,
  194.             int blockNum, int cacheFlags, 
  195.             LfsDiskAddr *diskAddressPtr));
  196. extern ReturnStatus LfsFile_SetIndex _ARGS_((Fsio_FileIOHandle *handlePtr, 
  197.             int blockNum, int blockSize, int cacheFlags, 
  198.             LfsDiskAddr diskAddress));
  199.  
  200. extern ReturnStatus LfsFile_TruncIndex _ARGS_((struct Lfs *lfsPtr, 
  201.             Fsio_FileIOHandle *handlePtr, 
  202.             int length));
  203.  
  204. extern ReturnStatus LfsFile_GrowBlock _ARGS_((Lfs *lfsPtr, 
  205.             Fsio_FileIOHandle *handlePtr,
  206.             int offset, int numBytes));
  207.  
  208. #endif /* _LFSINT */
  209.  
  210.